<template>
  <div class="app-container flex-cloumn">
    <el-form
        v-show="showSearch"
        ref="queryRef"
        :model="queryParams"
    >
      <el-row :gutter="12">
        <el-col :span="6">
          <el-form-item label="本方账户" prop="accIds">
            <baseCombox v-model="queryParams.accIds"
                        :style="{width: '100%'}"
                        clearable
                        multiple collapse-tags collapse-tags-tooltip
                        labelField="accName"
                        placeholder="本方账户"
                        size="small"
                        url="/trade/account/querySelfAccountCombox.action" valueField="accId"></baseCombox>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="挂钩标的" prop="instrumentId">

            <baseCombox url="/marketdata/instrument/getInstruments.action" clearable
                        size="small"
                        multiple collapse-tags collapse-tags-tooltip
                        valueField="code"
                        labelField="productName" placeholder="挂钩标的"
                        v-model="queryParams.instrumentIds"></baseCombox>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="交易日期">
            <el-date-picker
                v-model="queryParams.begDate"
                placeholder="选择开始日期"
                :disabled-date="disabledDateBeg"
                size="small"
                :style="{width: '100%'}"
                type="date"
                value-format="YYYY-MM-DD">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="-">
            <el-date-picker
                v-model="queryParams.endDate"
                placeholder="选择结束日期"
                :disabled-date="disabledDateEnd"
                size="small"
                :style="{width: '100%'}"
                type="date"
                value-format="YYYY-MM-DD">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="交易类型">
            <dictCombox v-model="queryParams.tradeTypes" collapse-tags multiple collapse-tags-tooltip
                        filterKey="LongOpen,LongClose,ShortOpen,ShortClose"
                        dictType="simpleTradeType" size="small"></dictCombox>
          </el-form-item>
        </el-col>
        <el-col :span="1.5">
          <el-button
              v-hasPermi="['pricing:otctrade:list']"
              icon="Search"
              style="margin: 3px 3px"
              size="mini"
              type="primary"
              @click="handleQuery"
          >搜索
          </el-button>
        </el-col>
      </el-row>
      <el-row :gutter="12" style="margin: 0 1px">
        <el-button
            v-hasPermi="['pricing:otctrade:insert']"
            icon="Plus"
            size="small"
            style="margin: 3px 3px"
            type="primary"
            @click="handleAdd"
        >新增
        </el-button>
        <el-button
            v-hasPermi="['pricing:otctrade:update']"
            :disabled="single"
            icon="Edit"
            size="small"
            style="margin: 3px 3px"
            type="success"
            @click="handleUpdate"
        >修改
        </el-button>
        <el-button
            v-hasPermi="['pricing:otctrade:delete']"
            :disabled="single"
            icon="Plus"
            style="margin: 3px 3px"
            size="small"
            type="danger"
            @click="handleDelete"
        >删除
        </el-button>
        <el-button
            v-hasPermi="['pricing:otctrade:export']"
            type="warning"
            plain
            icon="Download"
            style="margin: 3px 3px"
            size="small"
            @click="handleExport"
        >导出
        </el-button>
        <el-button
            type="warning"
            plain
            icon="Download"
            style="margin: 3px 3px"
            v-hasPermi="['pricing:otctrade:import']"
            size="small"
            @click="handleImport"
        >导入
        </el-button>
      </el-row>

    </el-form>
    <xTable ref="tradeRef" v-loading="loading" :data="tradeList" multiple="false" class="tableDragger_form"
            refId="tradeRef" @selection-change="handleSelectionChange" @row-dblclick="handleDbclick">
      <template #columList>
        <el-table-column label="序号" type="index" width="40"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" align="center" width="200px" label="交易编号"
                         prop="tradeId"></el-table-column>
        <el-table-column label="交易类型" prop="tradeType" show-overflow-tooltip>
          <template #default="scope">
            <dict-tag :options="simpleTradeType" :value="scope.row.tradeType"/>
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" align="center" label="交易日期" prop="tradeDate"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" align="center" label="标的代码" prop="iCode"/>
        <el-table-column :show-overflow-tooltip="true" align="left" label="标的名称" prop="iName"></el-table-column>
        <el-table-column label="市场类型" align="center" prop="mType" :show-overflow-tooltip="true">
          <template #default="scope">
            <dict-tag :options="M_TYPE" :value="scope.row.mType"/>
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" align="left" label="本方账户" prop="accName"></el-table-column>
        <el-table-column :formatter="formartEmptyTableP2" :show-overflow-tooltip="true" align="right" label="数量"
                         prop="volume"/>
        <el-table-column :formatter="formartEmptyTableP2" :show-overflow-tooltip="true" align="right" label="价格(元)"
                         prop="price"/>
        <el-table-column :formatter="formartEmptyTableP2" :show-overflow-tooltip="true" align="right" label="金额(元)"
                         prop="amount"/>
        <el-table-column :formatter="formartEmptyTableP2" :show-overflow-tooltip="true" align="right" label="费用(元)"
                         prop="fee"/>
        <el-table-column :show-overflow-tooltip="true" align="left" label="version" prop="version" v-if="false"/>
      </template>
    </xTable>
    <pagination
        style="margin:20px 0 20px 0"
        v-show="tradeTotal > 0"
        v-model:limit="queryParams.pageSize"
        v-model:page="queryParams.pageNum"
        :total="tradeTotal"
        @pagination="getList"
    />

    <!-- 执行时弹出 -->
    <el-dialog :close-on-click-modal="false"
               draggable="true"
               :title="tradeTitle"
               v-model="open"
               destroy-on-close="true"
               width="630px"
               append-to-body="true">
      <el-form ref="tradeFromRef" :model="data.tradeFrom" :rules="tradeRules">
        <el-form-item label="交易类型" prop="tradeType">
          <DictCombox v-model="data.tradeFrom.tradeType" dictType="simpleTradeType" clearable :disabled="disableFlag"
                      style="width:225px"
                      size="small"></DictCombox>
          <el-form-item label="本方账户" label-width="90px" prop="accId">
            <baseCombox v-model="data.tradeFrom.accId"
                        :disabled="disableFlag"
                        :style="{width: '100%'}"
                        clearable
                        labelField="accName"
                        placeholder="本方账户"
                        size="small"
                        style="width:225px"
                        url="/trade/account/querySelfAccountCombox.action" valueField="accId"></baseCombox>
          </el-form-item>
        </el-form-item>
        <el-form-item label="交易日期" prop="tradeDate">
          <el-date-picker
              v-model="tradeFrom.tradeDate"
              :disabled="disableFlag"
              placeholder="选择交易日期"
              size="small"
              style="width:225px"
              type="date"
              value-format="YYYY-MM-DD">
          </el-date-picker>
          <el-form-item label="标的" label-width="90px" prop="instrumentId">
            <Underlyer ref="underlyerIdRef" @change="instrumentchange" v-model="data.tradeFrom.instrumentId"
                       :disabled="disableFlag"
                       :underlyerId="data.tradeFrom.instrumentId" style="width:225px"/>
          </el-form-item>
        </el-form-item>
        <el-form-item label-width="66px" label="数量" prop="volume">
          <InputAmount @focus="volumeCal" :disabled="disableFlag2" v-model="data.tradeFrom.volume"
                       style="width:225px" maxlength="10"
                       precision="2"></InputAmount>
          <el-form-item label="价格" label-width="90px" prop="price">
            <InputAmount @focus="volumeCal" :disabled="disableFlag2" v-model="data.tradeFrom.price"
                         style="width:225px" append="元" maxlength="10"
                         precision="2"></InputAmount>
          </el-form-item>
        </el-form-item>
        <el-form-item label="金额" label-width="66px" prop="amountDirection">
          <el-select v-model="data.tradeFrom.amountDirection" :disabled="disableFlag2" placeholder="请选择"
                     style="width:60px" maxlength="30">
            <el-option label="支付" value="-1"/>
            <el-option label="收取" value="1"/>
          </el-select>
          <el-form-item prop="amount">
            <InputAmount @focus="amountCal" :disabled="disableFlag2" v-model="data.tradeFrom.amount"
                         style="width:165px" append="元"
                         precision="2"></InputAmount>
          </el-form-item>
          <el-form-item label="费用" label-width="90px" prop="feeDirection">
            <el-select :disabled="disableFlag2" v-model="data.tradeFrom.feeDirection" placeholder="请选择"
                       style="width:60px">
              <el-option label="支付" value='-1'/>
              <el-option label="收取" value='1'/>
            </el-select>
            <el-form-item prop="fee">
              <InputAmount v-model:value="data.tradeFrom.fee" style="width:165px" :disabled="disableFlag2" append="元"
                           precision="2"  maxlength="8"></InputAmount>
            </el-form-item>
          </el-form-item>
        </el-form-item>
        <el-form-item label="备注" label-width="66px" prop="remark">
          <el-input v-model="tradeFrom.remark" :disabled="disableFlag2" type="textarea" rows="3" maxlength="100"
                    show-word-limit
          />
        </el-form-item>
        <el-form-item label="version" label-width="66px" prop="version" v-if="false">
          <el-input v-model="tradeFrom.remark" :disabled="disableFlag2" type="text" rows="3" maxlength="100"
                    show-word-limit
          />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer" v-show="!disableFlag2">
          <el-button type="primary" @click="submit">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
    <el-dialog :title="upload.title" :close-on-click-modal="false" draggable="true" v-model="upload.open" width="400px"
               append-to-body>
      <el-upload
          ref="uploadRef"
          :limit="1"
          accept=".xlsx, .xls"
          :headers="upload.headers"
          :action="upload.url"
          :disabled="upload.isUploading"
          :on-progress="handleFileUploadProgress"
          :on-success="handleFileSuccess"
          :auto-upload="false"
          drag
      >
        <el-icon class="el-icon--upload">
          <upload-filled/>
        </el-icon>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <template #tip>
          <div class="el-upload__tip text-center">
<!--            <div class="el-upload__tip">-->
<!--              <el-checkbox v-model="upload.updateSupport"/>-->
<!--            </div>-->
            <span>仅允许导入xls、xlsx格式文件。</span>
            <el-link type="primary" :underline="false"
                     v-hasPermi="['pricing:otctrade:import']"
                     style="font-size:12px;vertical-align: baseline;"
                     @click="downTemplate">下载模板
            </el-link>
          </div>
        </template>
      </el-upload>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary"
                     v-hasPermi="['pricing:otctrade:import']"
                     @click="submitFileForm"
          >确定上传
          </el-button>
          <el-button @click="upload.open = false">取消上传</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="Simpletrade">
import {computed, ref, watch, watchEffect} from "vue";
import Underlyer from '@/xquant/base/underlyer'
import xTable from "@/xquant/base/xTable";
import {getToken} from "@/utils/auth";
import {formartFormP2} from '@/utils/numberUtil'
import DictCombox from "@/xquant/base/dictCombox"
import InputAmount from '@/xquant/base/InputAmount'
import {
  getOtcTradeByPage,
  insertTrade,
  updateTrade,
  deleteTrade,
  revertTrade,
} from "@/api/trade/otcoptiontrade";
import {sum} from "lodash";
import {formartEmptyTableP2} from "../../../utils/numberUtil";


const {proxy} = getCurrentInstance();
const {tradeType, M_TYPE, CURRENCY, simpleTradeType} = proxy.useDict(
    "tradeType",
    "CURRENCY",
    "M_TYPE",
    'simpleTradeType'
);

// 任务列表
const tradeList = ref([]);

// 修改框弹出
const open = ref(false);

// 修改框标题
const tradeTitle = ref("");
const fileName = ref("");
const fileType = ref("");
const loading = ref(true);
const showSearch = ref(true);
//
const ids = ref([]);
//索引
const indexs = ref([]);
const names = ref([]);
//数据
const rows = ref([]);
const single = ref(true);
const multiple = ref(true);
const single2 = ref(true);
const single3 = ref(true);
const single4 = ref(true);
const tradeTotal = ref(0);
const volumeWatch = ref(false);
const amountWatch = ref(false);
const action = ref("");
const num = ref(0)
const disableFlag = ref(false);
const updateFlag = ref(false);
const disableFlag2 = ref(false);
const upload = reactive({
  // 是否显示弹出层（用户导入）
  open: false,
  // 弹出层标题（用户导入）
  title: "",
  // 是否禁用上传
  isUploading: false,
  // 设置上传的请求头部
  headers: {Authorization: "Bearer " + getToken()},
  // 上传的地址
  url: import.meta.env.VITE_APP_BASE_API + "/pricing/trade/uploadSimpleTradeFile.action"
});
const data = reactive({
  tradeRules: {
    tradeType: [{required: true, message: "不能为空", trigger: "change"}],
    accId: [{required: true, message: "不能为空", trigger: "change"}],
    instrumentId: [{required: true, message: "不能为空", trigger: "change"}],
    tradeDate: [{required: true, message: "不能为空", trigger: "change"}],
    volume: [{required: true, message: "不能为空", trigger: "change"}, {
      validator: (rule, value, callback) => {
        return Number(value) > 0
      }, message: ' ', trigger: 'change'
    }],
    amount: [{required: true, message: " ", trigger: "change"}, {
      validator: (rule, value, callback) => {
        return Number(value) > 0
      }, message: ' ', trigger: 'change'
    }],
    price: [{required: true, message: "不能为空 ", trigger: "change"}, {
      validator: (rule, value, callback) => {
        return Number(value) > 0
      }, message: ' ', trigger: 'change'
    }],
    amountDirection: [{required: true, message: " ", trigger: "change"}],
    feeDirection: [{required: true, message: " ", trigger: "change"}],
    fee: [{required: true, message: " ", trigger: "change"}, {
      validator: (rule, value, callback) => {
        return Number(value) > 0
      }, message: ' ', trigger: 'change'
    }],
  },
  queryParams: {
    pageNum: 1,
    pageSize: 20,
    instrumentIds: null,
    accIds:null,
    tradeTypes:null,
    begDate:null,
    endDate:null,
    currency: 'CNY'
  },
  tradeFrom: {
    amountDirection: '1',
    feeDirection: '1',
    amount: 0,
    volume: 0,
    price: 0,
    version: ''
  },
});

const {queryParams, tradeRules, tradeFrom} = toRefs(data);

function volumeCal() {
  volumeWatch.value = true;
  amountWatch.value = false;
}

let lotSize = 1

function amountCal() {
  volumeWatch.value = false;
  amountWatch.value = true;
}

watch(() => tradeFrom.value.volume, (newv, oldv) => {
  if (isNaN(tradeFrom.value.amount)) {
    tradeFrom.value.amount = 0;
  }
  if (isNaN(tradeFrom.value.volume)) {
    tradeFrom.value.volume = 0;
  }
    if (volumeWatch.value) {
      lotSize = 1
      if (proxy.$refs.underlyerIdRef) {
        setTimeout(function () {
          lotSize = proxy.$refs.underlyerIdRef.underlyerIdsList[0].lotSize
          let num = (tradeFrom.value.volume * tradeFrom.value.price * lotSize).toFixed(4)
          tradeFrom.value.amount = num.substring(0, num.length - 1)
          // tradeFrom.value.amount = formartFormP2(tradeFrom.value.volume * tradeFrom.value.price * lotSize)
        }, 400);
      }
    }
})

watch(() => tradeFrom.value.price, (newv, oldv) => {
  if (isNaN(tradeFrom.value.amount)) {
    tradeFrom.value.amount = 0;
  }
  if (volumeWatch.value) {
    lotSize = 1
    if (proxy.$refs.underlyerIdRef) {
      setTimeout(function () {
        lotSize = proxy.$refs.underlyerIdRef.underlyerIdsList[0].lotSize
        let num = (tradeFrom.value.volume * tradeFrom.value.price * lotSize).toFixed(4)
        tradeFrom.value.amount = num.substring(0, num.length - 1)
        // tradeFrom.value.amount = formartFormP2(tradeFrom.value.volume * tradeFrom.value.price * lotSize)
      }, 400);
    }
  }
})

function sleep(ms) { //sleep延迟方法2
  var unixtime_ms = new Date().getTime();
  while (new Date().getTime() < unixtime_ms + ms) {
  }
}

function instrumentchange() {
  tradeFrom.value.price = 0
  tradeFrom.value.volume = 0
}

watch(() => tradeFrom.value.amount, (newv, oldv) => {
  if (isNaN(tradeFrom.value.price)) {
    tradeFrom.value.price = 0;
  }
  if (isNaN(tradeFrom.value.volume)) {
    tradeFrom.value.volume = 0;
  }
  if (amountWatch.value) {
    lotSize = 1
      if (proxy.$refs.underlyerIdRef) {
        setTimeout(function () {
          lotSize = proxy.$refs.underlyerIdRef.underlyerIdsList[0].lotSize
          // tradeFrom.value.amount = formartFormP2(tradeFrom.value.amount / (tradeFrom.value.price * lotSize))
          let num = (tradeFrom.value.amount / (tradeFrom.value.price * lotSize)).toFixed(4)
          tradeFrom.value.volume = num.substring(0, num.length - 1)
        }, 400);
      }
    }
})

const disabledDateBeg = (time) => {
  if (queryParams.value.endDate) {
    return time.getTime() > new Date(queryParams.value.endDate).getTime()
  }
}

const disabledDateEnd = (time) => {
  if (queryParams.value.begDate) {
    return time.getTime() < new Date(queryParams.value.begDate).getTime() - 86400000
  }
}

/** 查询按钮 */
function handleQuery() {
  getList();
}

/** 查询账户列表 */
function getList() {
  loading.value = false;
  let params = proxy.lsh.cloneDeep(queryParams.value)
  params.instruments=proxy.lsh.join(params.instrumentIds,'|');
  params.accIds=proxy.lsh.join(params.accIds,',');
  params.tradeTypes=proxy.lsh.join(params.tradeTypes,',');
  getOtcTradeByPage(params).then((response) => {
    tradeList.value = response.rows;
    tradeTotal.value = response.total;
    loading.value = false;
  });
}

// 添加场内交易
function handleAdd() {
  reset();
  open.value = true;
  disableFlag.value = false;
  disableFlag2.value = false;
  action.value = "save";
  tradeTitle.value = "新增场内交易";
  tradeFrom.value.tradeDate = proxy.$moment(new Date()).format("YYYY-MM-DD");
}

/**
 *
 * 任务  修改按钮操作
 * */
function handleUpdate() {
  reset();
  open.value = true;
  tradeTitle.value = "修改交易信息";
  tradeFrom.value = Object.assign({}, rows.value[0]);
  tradeFrom.value.instrumentId = rows.value[0].iCode + "," + rows.value[0].aType + "," + rows.value[0].mType
  if (tradeFrom.value.amount < 0) {
    tradeFrom.value.amountDirection = '-1';
    tradeFrom.value.amount = Math.abs(tradeFrom.value.amount)
  } else {
    tradeFrom.value.amountDirection = '1';
  }
  if (tradeFrom.value.fee < 0) {
    tradeFrom.value.feeDirection = '-1'
    tradeFrom.value.fee = Math.abs(tradeFrom.value.fee)
  } else {
    tradeFrom.value.feeDirection = '1'
  }
  disableFlag.value = true;
  disableFlag2.value = false;
  action.value = "update";
}

/** 导出按钮操作 */
function handleExport() {
  let params = proxy.lsh.cloneDeep(queryParams.value)
  params.instruments=proxy.lsh.join(params.instrumentIds,'|');
  params.accIds=proxy.lsh.join(params.accIds,',');
  params.tradeTypes=proxy.lsh.join(params.tradeTypes,',');
  proxy.download("pricing/trade/exportSimpleTrade.action", Object.assign({
    ...params
  }, {pageNum: '', pageSize: ''}), `场内交易${proxy.getCurrTime('YYYYmmddHHMMSS', new Date())}.xlsx`);
}

function handleImport() {
  upload.open = true;
}

// 下载模板
function downTemplate() {
  proxy.download("pricing/trade/downloadFile.action", Object.assign({
    fileName, fileType
  }, {fileName: "场内交易导入模板.xlsx", fileType: "xls,xlsx", businType: 'InnerTrade'}), `场内交易导入模板.xlsx`);
}

/**
 *
 * 修改/新增   保存操作
 * */
function submit() {
  proxy.$refs["tradeFromRef"].validate((valid) => {
    if (valid) {
      if (action.value == "update") {
        open.value = false;
        if (tradeFrom.value.amountDirection === '-1') {
          tradeFrom.value.amount = tradeFrom.value.amount * -1
        }
        if (tradeFrom.value.feeDirection === '-1') {
          tradeFrom.value.fee = tradeFrom.value.fee * -1
        }
        updateTrade(tradeFrom.value).then((response) => {
          if (response.success) {
            proxy.$modal.msgSuccess("修改成功");
            reset();
            disableFlag.value = false;
            getList();
          } else {
            proxy.$modal.msgError(response.msg);
          }
        });
      } else {
        open.value = false;
        if (tradeFrom.value.amountDirection === '-1') {
          tradeFrom.value.amount = tradeFrom.value.amount * -1
        }
        if (tradeFrom.value.feeDirection === '-1') {
          tradeFrom.value.fee = tradeFrom.value.fee * -1
        }
        tradeFrom.value.iCode = tradeFrom.value.instrumentId.split(",")[0]
        tradeFrom.value.aType = tradeFrom.value.instrumentId.split(",")[1]
        tradeFrom.value.mType = tradeFrom.value.instrumentId.split(",")[2]
        insertTrade(tradeFrom.value).then((response) => {
          if (response.success) {
            proxy.$modal.msgSuccess("新增成功");
            reset();
            getList();
          } else {
            proxy.$modal.msgError(response.msg);
          }
        });
      }
    }
  });
}

/**
 *
 * 多选框  选中数据
 * */
function handleSelectionChange(selection) {
  if (selection.length == 0) {
    ids.value = [];
    indexs.value = [];
    names.value = [];
    rows.value = [];
  } else {
    ids.value = selection.map((item) => item.tradeId);
    indexs.value = selection.map((item) => item.index);
    rows.value = selection.map((item) => item);
  }
  single.value = selection.length != 1;
  multiple.value = !selection.length;
  if (selection.length == 1) {
  }
  if (selection.length != 1) {
  }
}

/** 删除按钮操作 */
function handleDelete() {
  proxy.$modal
      .confirm('是否确认删除交易编号为 "' + ids.value[0] + '"的数据项？')
      .then(function () {
        return deleteTrade(rows.value[0]);
      })
      .then(() => {
        getList();
        proxy.$modal.msgSuccess("删除成功");
      })
      .catch(() => {
      });
}

// 撤单
function handleRevert() {
  proxy.$modal
      .confirm('是否撤销交易编号为 "' + ids.value[0] + '"的数据项？')
      .then(function () {
        return revertTrade(rows.value[0]);
      })
      .then(() => {
        getList();
        proxy.$modal.msgSuccess("撤单成功");
      })
      .catch(() => {
      });
}

/** 取消添加按钮 */
function cancel() {
  open.value = false;
  disableFlag.value = false;
  reset();
}

/** 表单重置 */
function reset() {
  tradeFrom.value = {};
  tradeFrom.value.amountDirection= '1';
  tradeFrom.value.feeDirection = '1';
  tradeFrom.value.amount = 1000;
  tradeFrom.value.volume = 10;
  tradeFrom.value.price = 100;
  tradeFrom.value.fee = 100;
  tradeFrom.value.instrumentId = '000905,IDX_S,XSHG';
  proxy.resetForm("tradeFromRef");
}

/**文件上传中处理 */
const handleFileUploadProgress = (event, file, fileList) => {
  upload.isUploading = true;
};

/** 文件上传成功处理 */
const handleFileSuccess = (response, file, fileList) => {
  upload.open = false;
  upload.isUploading = false;
  proxy.$refs["uploadRef"].clearFiles();
  proxy.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", {dangerouslyUseHTMLString: true});
  getList();
};

/** 提交上传文件 */
function submitFileForm() {
  proxy.$refs["uploadRef"].submit();
};

function handleDbclick(row, column, event) {
  reset();
  open.value = true;
  tradeTitle.value = "查看交易信息";
  tradeFrom.value = row;
  tradeFrom.value.instrumentId = row.iCode + "," + row.aType + "," + row.mType
  if (tradeFrom.value.amount < 0) {
    tradeFrom.value.amountDirection = '-1';
    tradeFrom.value.amount = Math.abs(tradeFrom.value.amount)
  } else {
    tradeFrom.value.amountDirection = '1';
  }
  if (tradeFrom.value.fee < 0) {
    tradeFrom.value.feeDirection = '-1'
    tradeFrom.value.fee = Math.abs(tradeFrom.value.fee)
  } else {
    tradeFrom.value.feeDirection = '1'
  }
  disableFlag.value = true;
  disableFlag2.value = true;
}

getList();
</script>
